<?php if(count($comments) > 3){ ?>
	<div class="ovh">
		<div class="c">
			<div class="more_btn cc more_child_comments">Показать больше сообщений</div>
		</div>
	</div>
<?php } ?>

<?php foreach($comments as $key=>$comment){ ?>	
	<?php $class = ((count($comments) - $key) >= 4) ? 'hidden' : ''; ?>
	<div class="u_buzz_item child_u_buzz_item <?php echo $class; ?>">
		<div class="u_buzz_item_l">
			<a href="<?php echo Yii::app()->createUrl('profile/index', array('id'=>$comment->user_info->id));?>">
				<?php if($comment->user_info->avatar_info){ ?>
					<?php echo $this->material_image('', $comment->user_info->avatar_info->name, '50', 'photos/'. $comment->user_info->id . '/' . 0); ?>
				<?php }else{ ?>
					<?php echo $this->material_image('', 'noimage.gif', '50', ''); ?>
				<?php } ?>
			</a>
		</div>
		<div class="u_buzz_item_r">
			<div class="u_buzz_name">
				<a href="<?php echo Yii::app()->createUrl('profile/index', array('id'=>$comment->user_info->id));?>" class="profileName">
					<?php echo CHtml::encode($comment->user_info->full_name); ?>
				</a>
				<?php $date_diff = date_diff(date_create($comment->crdate), date_create()); ?>
				<?php if($date_diff->h){ ?>
					<span class="u_buzz_date"><?php echo Yii::app()->dateFormatter->formatDateTime($comment->crdate, 'long','short'); ?></span>
				<?php }else{ ?>
					<span class="u_buzz_date"><?php echo $date_diff->i; ?> мин. назад</span>
				<?php } ?>
				<div class="u_buzz_link_block hidden">
					<?php if(($comment->user_info->id == Yii::app()->user->id) || (Yii::app()->user->id == $_GET['id'])){ ?>
						<a href="<?php echo Yii::app()->createAbsoluteUrl("groupsDiscussion/deletecomment", array('comment_id'=>$comment->id)); ?>" class="u_buzz_link l2 comment_delete" rel="<?php echo $parent_id; ?>" onclick="return false;">
							<div class="user_action_item_tooltip c hidden"><div class="cc">Удалить сообщение</div></div>
						</a>
					<?php } ?>
					
					<?php if($comment->user_info->id != Yii::app()->user->id){ ?>
						<div class="copyme">
							<a href="<?php echo Yii::app()->createUrl('profile/insertcomment', array('id'=>Yii::app()->user->id)); ?>" class="u_buzz_link  copycomment">
								<div class="user_action_item_tooltip c hidden"><div class="cc">Поделиться</div></div>
							</a>
							<input type="hidden" value="<?php echo $comment->text; ?>" class="copytext" />
							<?php $images = ''; ?>
							<?php foreach($comment->images as $image){ ?>
								<?php $images .= $image->photo->id . ','; ?>
							<?php } ?>							
							<input type="hidden" value="<?php echo $images; ?>" class="copyimage" />
							<?php $videos = ''; ?>
							<?php foreach($comment->videos as $video){ ?>
								<?php $videos .= $video->video->id . ','; ?>
							<?php } ?>							
							<input type="hidden" value="<?php echo $videos; ?>" class="copyvideo" />				
							<?php $musics = ''; ?>
							<?php foreach($comment->musics as $music){ ?>
								<?php $musics .= $music->music->id . ','; ?>
							<?php } ?>							
							<input type="hidden" value="<?php echo $musics; ?>" class="copymusic" />											
						</div>
					<?php } ?>					
				</div>
			</div>
			<p class="u_buzz_text">
				<?php echo nl2br(CHtml::encode(rawurldecode($comment->text))); ?>
				
				<div class="commentPhoto">
					<?php foreach($comment->images as $image){ ?>
						<?php if($image->photo){ ?>
							<div class="commentPhotoItem">
								<a href="<?php echo Yii::app()->createUrl('albums/photo', array('id'=>$image->photo->id));?>" class="photoBg">
									<?php echo $this->material_image($image->photo->album_id, $image->photo->name, '270', 'photos/'. $image->photo->user_id . '/' . $image->photo->album_id); ?>
								</a>
							</div> 
						<?php } ?>
					<?php } ?>
				</div>
				<div class="commentVideo">
					<?php foreach($comment->videos as $video){ ?>
						<div class="commentVideoItem"><?php echo $video->video->code; ?></div>
					<?php } ?>	
				</div>
				<div class="commentMusic">
					<?php foreach($comment->musics as $music){ ?>
						<div class="u_audio__item">
							<div class="play_btn pause"></div>
							<div class="u_audio_track">
								<?php if($music->music->artist){ ?>
									<a class="u_audio__autor" href="#"><?php echo CHtml::encode($music->music->artist); ?></a>
									<span> &mdash; </span>
								<?php } ?>
								<a class="u_audio__name" href="#"><?php echo CHtml::encode($music->music->name); ?></a>
							</div>
						</div>	
					<?php } ?>
				</div>									
			</p>

			<p class="u_buzz_comment_link">			
				<?php $this->renderPartial('_commentLikes',array(
					'comment_id' => $comment->id,
					'countLikes' => $comment->countLikes,
					'likes'	=> $comment->likes,
					'childComments' => $comment->childComments
				)); ?>	
			</p>		
		</div>
	</div>
<?php } ?>
